Skip to content

feat: introduce apiExportPolicy resource#401

Merged
OlegErshov merged 28 commits intomainfrom
feat/introduce-apiexport-policy-resource
Mar 26, 2026
Merged

feat: introduce apiExportPolicy resource#401
OlegErshov merged 28 commits intomainfrom
feat/introduce-apiexport-policy-resource

Conversation

@OlegErshov
Copy link
Copy Markdown
Contributor

@OlegErshov OlegErshov commented Mar 10, 2026

On-behalf-of: SAP aleh.yarshou@sap.com

This pr resolves this issue #228

Changes:

  1. Introduce a new APIExportPolicy resource
  2. Introduce a separate cobra command for authorization.platform-mesh.io apiexport.
  3. In implementation was highly used direct client creation, because it's impossible to discover any other logical cluster in which there's no system.platform-mesh.io apiBinding and we decided to have system.platform-mesh.io apiBinding only in platform-mesh-system ans orgs workspaces

Process function flow:

  1. get provider's cluster ID for tuples creation
  2. Remove tuples for deleted expressions from spec
  3. Process expressions one by one in a loop
  4. Parse an expression to get a needed relation (bind, bind_inherited) and workspace path (root:orgs:A) for future client creation
  5. if workspace path is root:orgs:* we need to get cluster ID for every organization workspace, for this we can use allClient and list every accountInfo resource with type=org filter. It's convenient because in accountInfo resource we have all needed information (StoreID, clusterID)
  6. if workspace path is different from root:orgs:*, it means that this is workspace has accountInfo resource. Controller fetches accountInfo resource to get (StoreID, clusterID) information and after creates tuples.

For finalization logic is the same, only tuples are being deleted.

This approach has a downside in extra tuples creation terms.
If somebody creates a resource with these expressions:

:root:orgs:*
:root:orgs:A:*
:root:orgs:A:B
:root:orgs:C

OpenFGA will have a bunch of pointless tuples, because binding permissions were granted for every workspace by this expression :root:orgs:* and the rest of the expressions are redundant. But expressions validation should be addressed on validating webhook level.

On-behalf-of: SAP aleh.yarshou@sap.com
@OlegErshov OlegErshov self-assigned this Mar 10, 2026
On-behalf-of: SAP aleh.yarshou@sap.com
OlegErshov and others added 20 commits March 10, 2026 18:29
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
@OlegErshov OlegErshov marked this pull request as ready for review March 24, 2026 17:23
@OlegErshov OlegErshov requested review from a team as code owners March 24, 2026 17:23
Copy link
Copy Markdown
Contributor

@akafazov akafazov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. Left some minor comments including a request to cover happy path with fga mocks in the unit tests.

Comment thread internal/client/all_platformmesh.go Outdated
Comment thread internal/subroutine/apiexportpolicy.go Outdated
@akafazov akafazov self-requested a review March 25, 2026 14:37
Comment thread internal/subroutine/apiexportpolicy_test.go
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
…t interface

On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
Copy link
Copy Markdown
Contributor

@akafazov akafazov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@OlegErshov OlegErshov merged commit 81ded41 into main Mar 26, 2026
11 checks passed
@OlegErshov OlegErshov deleted the feat/introduce-apiexport-policy-resource branch March 26, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants